import request from '@/api/request'
import axios from 'axios'
import { getToken } from '@/utils/auth'
import { getConfig } from '@/config/config'
import CryptoJS from "crypto-js"

const api = {
  // 根据船员id获取证书列表
  getList(query) {
    return request({
      url: '/tug-api/plan/disLog/page',
      method: 'get',
      params: query
    })
  },
  // 根据Id查询单条
  getDetailById(id) {
    return request({
      url: `/tug-api/plan/disLog/${id}`,
      method: 'get'
    })
  },
  // 新建
  save(data) {
    return request({
      url: '/tug-api/plan/disLog/save',
      method: 'post',
      data: data
    })
  },
  // 修改
  update(data) {
    return request({
      url: '/tug-api/plan/disLog/update',
      method: 'post',
      data: data
    })
  },
  //删除
  remove(ids) {
    return request({
      url: `/tug-api/plan/disLog/remove`,
      method: 'post',
      params: ids
    })
  },
  //导出模板
  exportTemplate() {
  	  return axios({
  	  		url: `/tug-api/plan/disLog/exportTemplate`,
  	  		method: 'get',
  	  		responseType:'blob',
  	  		headers: {
  	  			  'Authorization' : `Basic ${CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(`${getConfig('clientId')}:${getConfig('clientSecret')}`))}`,
  	  			 'qdport-Auth': 'bearer ' + getToken(),
					 'token':getToken()
  	  		  },
  	  	})
  },
  //导出数据
  exportData(params) {
  	  return axios({
  	  		url: `/tug-api/plan/disLog/exportData`,
  	  		method: 'get',
  	  		responseType:'blob',
  			params:params,
  	  		headers: {
  	  			  'Authorization' : `Basic ${CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(`${getConfig('clientId')}:${getConfig('clientSecret')}`))}`,
  	  			 'qdport-Auth': 'bearer ' + getToken(),
					 'token':getToken()
  	  		  },
  	  	})
  },
  //导入
  importData(data) {
    return http({
      url: `/tug-api/plan/disLog/importLog`,
      method: 'post',
      data: data
    })
  },
}
export default api

